//
//  BaseRequest.m
//  NBAApp
//
//  Created by 刘意明 on 16/11/30.
//  Copyright © 2016年 Manito. All rights reserved.
//

#import "BaseRequest.h"
#import <AFNetworking.h>
static BaseRequest *baseRequest;
@implementation BaseRequest
+ (instancetype)shareInstance
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        baseRequest =[[BaseRequest alloc] init];
    });
    return baseRequest;
}

//基础的网络请求 GRT
-(void)startGetWithURL:(NSString *)url params:(NSDictionary *)params success:(SuccessBlock)seccessBass failure:(FailureBlock)FailureBlock
{
    AFHTTPSessionManager *manager =[AFHTTPSessionManager manager];
    
    //
    manager.responseSerializer=[AFHTTPResponseSerializer serializer];
    
    
    [manager GET:url parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        id result =[NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
        
        seccessBass(result);
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        FailureBlock(error);
    }];
}

//POST
-(void)startPostWithURL:(NSString *)url params:(NSDictionary *)params success:(SuccessBlock)seccessBass failure:(FailureBlock)FailureBlock
{

}

@end
